<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div class="box">
        <h2>今天天气很{{info}}</h2>
        <button class="btn" @click="changeWeather">点我更换天气</button>
    </div>
</body>
<script>
    var head2 = document.querySelector('h2')
    var btn = document.querySelector('.btn')

    var vm = new Vue({
        el:'.box',
        data() {
            return {
                isHot:true,
            }
        },
        methods: {
            changeWeather(){
                this.isHot = this.isHot?false:true
            }
        },
        computed:{
            info:{
                get(){
                    return this.isHot?'炎热':'凉爽'
                }
            },
        },
        watch: {
            isHot:{
                handler(newValue,oldValue){
                    //当isHot发生改变时会调用
                }
            }
        },
    })
</script>
</html>